﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.Util;
using Com.CMS263.PO;
using Com.CMS263.BLL;
using System.IO;

namespace Com.CMS263.Web.manage.VoteManage
{
    public partial class vote_edit : System.Web.UI.Page
    {
        VoteTopicBLL pbll = new VoteTopicBLL();
        public VoteTopic ab = new VoteTopic();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
               
                BindData();
            }
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string title = StringUtil.checkStr(Request["txtTitle"]);
            
            string sortid = StringUtil.checkStr(Request["txtSortId"]);   
            if (string.IsNullOrEmpty(title))
            {
                StringUtil.Alert("名称不能为空", "-1");
            }

           
            int id = Convert.ToInt32(Request["id"]);
            if (id <= 0)
            {
                StringUtil.Alert("抱歉，没有找到相关数据", "vote_list.aspx");
            }
            VoteTopic prod = new VoteTopic();
            prod = (VoteTopic)pbll.FindModelById("VoteTopic", id);
            prod.SortId = Convert.ToInt32(sortid);
            prod.Title = title;
            prod.ListId = 0;
            prod.VoteType = Convert.ToInt32(Request["selType"]);
            pbll.entity = prod;
            if (pbll.UpDate())
            {
                StringUtil.Alert("修改成功", "vote_list.aspx");
            }


        }
        public void BindData()
        {
            int id = Convert.ToInt32(Request["id"]);
            if (id <= 0)
            {
                StringUtil.Alert("抱歉，没有找到相关数据", "vote_list.aspx");
            }
            ab = (VoteTopic)pbll.FindModelById("VoteTopic", id);
        }
    }
}
